home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / ww_tv.exe / TEDITOR4.CPP < prev    next >
C/C++ Source or Header  |  1992-01-06  |  7KB  |  180 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*                    Copyright (c) 1991 Primatech Inc.                     */
  4. /*                                                                          */
  5. /*                           All Rights Reserved                            */
  6. /*                                                                          */
  7. /****************************************************************************/
  8.  
  9.  
  10.  
  11. // $config$=/MTEditor4.cpp
  12. //
  13. //  $NAME$:
  14. //          ..Module Overview
  15. //
  16. //  $GLOBAL PATHS$
  17. //          modules\all\TEditor4.cpp
  18. //          modules\c++\TEditor4.cpp
  19. //          objects\TEditor
  20. //
  21. //  $0$
  22. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  23. //
  24. //  Purpose:    Word wrap function for TEditor
  25. //
  26. //  Prototypes location:    $/SEE(Editors.h)$
  27. //
  28. //  Other Information:
  29. //
  30. //  See also:       $/SEE()$
  31. //
  32. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  33.  
  34.  
  35. //$-1$
  36. #if 0
  37. //$1$
  38. /**** MODIFICATIONS HISTORY ****/
  39.  
  40. Created:        12 November 1991 by John L. Swartzentruber
  41.  
  42.  
  43. $SKIP START$
  44. #endif
  45.  
  46. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  47. /*+                                                                        +*/
  48. /*+                       I N C L U D E   F I L E S                        +*/
  49. /*+                                                                        +*/
  50. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  51. #define Uses_TEditor
  52. #include <tv.h>
  53.  
  54.  
  55. //$SKIP END$
  56. //$2$
  57. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  58. /*+                                                                        +*/
  59. /*+       # D E F I N E S    C L A S S E S   and    T Y P E D E F S        +*/
  60. /*+                                                                        +*/
  61. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  62.  
  63.  
  64.  
  65. //$3$
  66. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  67. /*+                                                                        +*/
  68. /*+                E X T E R N A L    D E F I N I T I O N S                +*/
  69. /*+                                                                        +*/
  70. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  71.  
  72.  
  73. //$4$
  74. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  75. /*+                                                                        +*/
  76. /*+                  S T A T I C    D E F I N I T I O N S                  +*/
  77. /*+                                                                        +*/
  78. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  79.  
  80.  
  81.  
  82. //$END$
  83. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  84. /*+                                                                        +*/
  85. /*+          S T A T I C   F U N C T I O N   P R O T O T Y P E S           +*/
  86. /*+                                                                        +*/
  87. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  88.  
  89.  
  90.  
  91. /* EJECT */
  92. //****************************************************************************
  93. //
  94. //      Function $NAME$:
  95. //                          TEditor::wordWrapBuffer(ushort,ushort)
  96. //                                                                            $1$
  97. // 
  98. //      Purpose:    To word wrap the buffer.  This is always done, regardless
  99. //                  of the value of wordWrap.  Consequently, don't call this
  100. //                  function if wordWrap is False.
  101. //
  102. //      Parameters:
  103. //
  104. //          ushort linePtr:     Where word-wrapping should begin.  This
  105. //                              is an offset into the buffer, and it MUST
  106. //                              be the beginning of a line.  This will
  107. //                              usually be the beginning of the line before
  108. //                              the line containing curPtr.
  109. //
  110. //          ushort minchars:    The minumum number of characters that the
  111. //                              word wrapping function will process before
  112. //                              deciding that there is nothing to wrap.  This
  113. //                              should usually be set to ensure that the
  114. //                              current line (and any new data) are checked.
  115. //
  116. //
  117. //      Return:     The WordWrapState (wwsDidWrap, wwsNoWrap, wwsError)
  118. //
  119. //      Other information:
  120. //
  121. //          This function handles an error by calling the editorDialog with
  122. //          an out of memory error.
  123. //
  124. //$0$
  125. //****************************************************************************
  126. WordWrapState TEditor::wordWrapBuffer(ushort linePtr, ushort minchars)
  127. //                                                                            $END$
  128. {
  129.     short line_delta = 0;
  130.  
  131.     WordWrapState wrap_rc = doWordWrapBuffer(linePtr, minchars, &line_delta);
  132.  
  133.     if (wrap_rc == wwsError) {
  134.         editorDialog( edOutOfMemory );
  135.  
  136.     } else if (wrap_rc == wwsDidWrap) {
  137.  
  138.         // If we wrapped, completely recalculate which line we are on
  139.         curPos.y = countLines(buffer, curPtr);
  140.  
  141.         drawLine = curPos.y;
  142.         drawPtr = lineStart(curPtr);
  143.         curPos.x = charPos(drawPtr, curPtr);
  144.  
  145.         limit.y += line_delta;
  146.         delta.y = max(0, min(delta.y, limit.y - size.y));
  147.         delta.x = max(curPos.x - size.x + 1, 0);
  148.  
  149.         update(ufView);
  150.     }
  151.  
  152.     return wrap_rc;
  153. }
  154.  
  155.  
  156. /* EJECT */
  157. //****************************************************************************
  158. //
  159. //      Function $NAME$:
  160. //                          TEditor::changeBufSize(short)
  161. //                                                                            $1$
  162. // 
  163. //      Purpose:    This is a non-virtual function that calls the virtual
  164. //                  function setBufSize().  It is defined so that an
  165. //                  assembly language function can easily call the virtual
  166. //                  function to increase or decrease the size of the buffer.
  167. //
  168. //      Return:     same as setBufSize() (True on success, False on failure)
  169. //
  170. //      Other information:
  171. //
  172. //$0$
  173. //****************************************************************************
  174. Boolean TEditor::changeBufSize( short change )
  175. //                                                                            $END$
  176. {
  177.     return setBufSize(bufSize + change);
  178. }
  179.  
  180.